﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Sql;

namespace Testowanie
{
    public partial class Form1 : Form
    {
        System.Data.OleDb.OleDbConnection con;
       // DataSet ds1;
      public  System.Data.OleDb.OleDbDataAdapter da;
       public DataRow dRow;
      public  int wiersz;
      public int kolumna;
        int MaxRows = 0;
        int inc = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 forma2= new Form2(this);
           // forma2.start(this);
            forma2.Show();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        public DataSet MyDataSet
        {
            get
            {
                return northwindDataSet;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            con = new System.Data.OleDb.OleDbConnection();
           // ds1 = new DataSet();
            con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:/northwind.mdb";
            string sql = "SELECT * From Auto";
            da = new System.Data.OleDb.OleDbDataAdapter(sql, con);  
            con.Open();
            da.Fill(this.northwindDataSet, "Auto");
           // con.Close();
          //  con.Dispose();
            // TODO: This line of code loads data into the 'northwindDataSet.Auto' table. You can move, or remove it, as needed.
            da.Update(this.northwindDataSet, "Auto");
            // this.autoTableAdapter.Fill(this.northwindDataSet.Auto);
            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            wiersz = dataGridView1.CurrentCell.RowIndex;
         //   this.autoTableAdapter.Update(dRow);
          //  this.autoTableAdapter.Fill(this.northwindDataSet.Auto);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Form2 forma2 = new Form2(this);
            forma2.Show();
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(da);
            dRow = this.northwindDataSet.Tables["Auto"].NewRow();
       //     dRow[0] = textBox1.Text;
         //   this.northwindDataSet.Tables["Auto"].Rows.Add(dRow);

            //MaxRows
          //  da.Update(this.northwindDataSet, "Auto");
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            wiersz = dataGridView1.CurrentCell.RowIndex;
            kolumna = dataGridView1.CurrentCell.ColumnIndex;
            Form3 forma3 = new Form3(this);
            // forma2.start(this);
            forma3.Show();
        }

      /*  private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {

        }*/
    }
}


/*
 

*/
